<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--360浏览器优先以webkit内核解析-->
    <title>欢迎页</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/main/animate.min.css" th:href="@{/css/main/animate.min.css}" rel="stylesheet"/>
    <link href="../static/css/main/style.min862f.css" th:href="@{/css/main/style.min862f.css}" rel="stylesheet"/>
    <th:block th:include="include :: header('百度ECharts')" />
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>各会长当月订购单金额</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">选项1</a>
                            </li>
                            <li><a href="#">选项2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="echarts" id="echarts-pie-chart"></div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>各月份订购金额</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">选项1</a>
                            </li>
                            <li><a href="#">选项2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">

                    <div class="echarts" id="echarts-bar-chart"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div style="margin-top: 10px;">
    <div style="display: flex">
        <div style="flex: 1;cursor: pointer" onclick="partsCodeReview();">
            <div class="ibox" style="border: #c23531 solid 2px;margin: 20px 50px;background: #c23531">
                <div class="ibox-content" style="text-align: center">
                    <h4>补助金待审核</h4>
                    <h1 id="partsPayReviewNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
        <div style="flex: 1;cursor: pointer" onclick="agentOrderCurrent()">
            <div class="ibox" style="border: #c23531 solid 2px;margin: 20px 50px;background: #c23531">
                <div class="ibox-content" style="text-align: center">
                    <h4>大区会长今日预订单</h4>
                    <h1 id="agentOrderNuM" class="no-margins">0</h1>
                </div>
            </div>
        </div>
        <div style="flex: 1;cursor: pointer;" onclick="storeApplyUnDeal();">
            <div class="ibox" style="border: #c23531 solid 2px;margin: 20px 50px;background: #c23531">
                <div class="ibox-content" style="text-align: center">
                    <h4>入驻申请待审核</h4>
                    <h1 id="storeApplyNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
        <div style="flex: 1;cursor: pointer" onclick="factoryApplyReview();">
            <div class="ibox" style="border: #c23531 solid 2px;margin: 20px 50px;background: #c23531">
                <div class="ibox-content" style="text-align: center" >
                    <h4>合作厂家待审核</h4>
                    <!--<h1 id="chunSum" class="no-margins">0</h1>-->
                    <h1 id="factoryApplyNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
    </div>
    <div style="display: flex;margin-top: 10px;">
        <div style="flex: 1;cursor: pointer" onclick="qrcodeApplyCurrent();">
            <div class="ibox" style="border: #2f4554 solid 2px;margin: 20px 50px;background: #2f4554">
                <div class="ibox-content" style="text-align: center">
                    <h4>今日产品二维码申请单</h4>
                    <!--<h1 id="chunSum" class="no-margins">0</h1>-->
                    <h1 id="qrcodeApplyNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
        <div style="flex: 1;cursor: pointer" onclick="serviceOrderUnDeal();">
            <div class="ibox" style="border: #2f4554 solid 2px;margin: 20px 50px;background: #2f4554">
                <div class="ibox-content" style="text-align: center" >
                    <h4>待处理服务单</h4>
                    <!--<h1 id="chunSum" class="no-margins">0</h1>-->
                    <h1 id="serviceOrderNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
        <div style="flex: 1;cursor: pointer" onclick="cooperateApplyUnDeal();">
            <div class="ibox" style="border: #2f4554 solid 2px;margin: 20px 50px;background: #2f4554">
                <div class="ibox-content" style="text-align: center">
                    <h4>待处理合作申请</h4>
                    <!--<h1 id="chunSum" class="no-margins">0</h1>-->
                    <h1 id="cooperateApplyNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
        <div style="flex: 1;cursor: pointer" onclick="electrictOrderUnDeal()">
            <div class="ibox" style="border: #2f4554 solid 2px;margin: 20px 50px;background: #2f4554">
                <div class="ibox-content" style="text-align: center">
                    <h4>待处理整机服务单</h4>
                    <h1 id="electrictOrderNum" class="no-margins">0</h1>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: echarts-js" />
<script type="text/javascript">
    $(function () {
        //获取当月大区会长订购单
        $.ajax({
            type: "post",
            url: ctx + "zsyh/agentOrder/listCurrentMonth",
            success: function(r) {
                debugger;
                var orderDatas=[];
                var agentNameDatas=[];
                var orderData=r.rows;
                for(var i=0;i<orderData.length;i++){
                    var data={};
                    data["value"] = orderData[i].orderBeginMoney;
                    data["name"]=orderData[i].agentName;
                    orderDatas.push(data);
                    agentNameDatas.push(orderData[i].agentName);
                }
                //获取当前年月
                var myDate = new Date();
                var pieChart = echarts.init(document.getElementById("echarts-pie-chart"));
                var pieoption = {
                    title : {
                        text: '各会长当月订购单金额',
                        subtext: myDate.getFullYear()+'年'+(myDate.getMonth()+1)+'月',
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient : 'vertical',
                        x : 'left',
                        data: agentNameDatas
                    },
                    calculable : true,
                    series : [
                        {
                            name:'当月订购额',
                            type:'pie',
                            radius : '60%',
                            center: ['50%', '60%'],
                            data: orderDatas
                        }
                    ]
                };
                pieChart.setOption(pieoption);
                $(window).resize(pieChart.resize);
            }
        });


        $.ajax({
            type: "post",
            url: ctx + "zsyh/agentOrder/listCurrentYear",
            success: function(r) {
                debugger;
                var agentMoneyDatas=[];
                var agentNumDatas=[];
                var orderData=r.rows;
                for(var i=0;i<orderData.length;i++){
                    agentMoneyDatas.push(orderData[i].orderBeginMoney);
                    agentNumDatas.push(orderData[i].orderNum);
                }
                //获取当前年月
                var myDate = new Date();
                var barChart = echarts.init(document.getElementById("echarts-bar-chart"));
                var baroption = {
                    title : {
                        text: myDate.getFullYear()+'年产品订购金额分布'
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:['订购额','订购单']
                    },
                    grid:{
                        x:30,
                        x2:40,
                        y2:24
                    },
                    calculable : true,
                    xAxis : [
                        {
                            type : 'category',
                            data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value',
                            name: "单位(万元)",
                        }
                    ],
                    series : [
                        {
                            name:'订购额',
                            type:'bar',
                            data:agentMoneyDatas,
                        },
                        {
                            name:'订购单',
                            type:'bar',
                            data:agentNumDatas,
                        }
                    ]
                };
                barChart.setOption(baroption);

                window.onresize = barChart.resize;
            }
        });
    })

    $.ajax({
        type: "post",
        url: ctx + "zsyh/report/listReport",
        success: function(r) {
            debugger;
            var orderDatas=[];
            var agentNameDatas=[];
            var orderData=r.rows;
            $("#partsPayReviewNum").html(r.data.partsPayReviewNum);
            $("#agentOrderNuM").html(r.data.agentOrderNuM);
            $("#storeApplyNum").html(r.data.storeApplyNum);
            $("#factoryApplyNum").html(r.data.factoryApplyNum);
            $("#qrcodeApplyNum").html(r.data.qrcodeApplyNum);
            $("#serviceOrderNum").html(r.data.serviceOrderNum);
            $("#cooperateApplyNum").html(r.data.cooperateApplyNum);
            $("#electrictOrderNum").html(r.data.electrictOrderNum);
        }
    });


    function partsCodeReview() {
        $.modal.openTab("补助金待审核", ctx + "zsyh/partsQrcodeApply/partsQrcodeApplyReview");
    }

    function storeApplyUnDeal() {
        $.modal.openTab("入驻申请待审核", ctx + "zsyh/repairStore/repairStoreUnDeal");
    }

    function factoryApplyReview() {
        $.modal.openTab("合作厂家待审核", ctx + "zsyh/factory/factoryApplyReview");
    }

    function serviceOrderUnDeal() {
        $.modal.openTab("待处理服务单", ctx + "zsyh/serviceOrder/serviceOrderUnDeal");
    }

    function cooperateApplyUnDeal() {
        $.modal.openTab("待处理合作申请", ctx + "zsyh/userCooperation/cooperateApplyUnDeal");
    }

    function electrictOrderUnDeal() {
        $.modal.openTab("待处理整机服务单", ctx + "zsyh/electricOrder/electrictOrderUnDeal");
    }

    function agentOrderCurrent() {
        $.modal.openTab("大区会长今日预订单", ctx + "zsyh/agentOrder/agentOrderCurrent");
    }

    function qrcodeApplyCurrent() {
        $.modal.openTab("今日产品二维码申请单", ctx + "zsyh/qrcodeHistory/qrcodeApplyCurrent");
    }

</script>
</body>
</html>
